<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>登录</title>
    <link rel="stylesheet" href="../../libs/node_modules/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../style/common.css">
    <link rel="stylesheet" href="../../style/home/article.css">
    <link rel="stylesheet" href="../../style/login/login.css">
    <script src="../../libs/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="../../libs/jquery-3.2.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="../../libs/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="../../libs/layer-v3.1.1/layer/layer.js"></script>
    <script src="../../libs/node_modules/echarts/dist/echarts.js"></script>
    <!--<script src="js/system.js"></script>-->
</head>
<body>
<div id="app">


<header-component></header-component>
<navinner-component></navinner-component>
<navrow-component></navrow-component>
<main>
    <div class="content">
        <div class="login-container">
            <div class="login-container-l">
                <div class="login-title">城乡家园服务网</div>
                <img src="../../static/images/tu邓丽.png" alt="">
            </div>
            <div class="login-container-r">
                <div class="login-box">
                    <div class="login-header">
                        <div :class="{'login-header-user login-tab':active!=1 ,'login-header-user active login-tab':active==1}" @click="exchange(1)">
                            用户登录
                        </div>
                        <div :class="{'login-header-user login-tab':active!=2 ,'login-header-user active login-tab':active==2}" @click="exchange(2)">
                            站长登录
                        </div>
                    </div>
                    <form class="login-content" name="content">
                        <div class="login-input">
                            <img src="../../static/icons/用户名.png" alt="">
                            <input type="text" placeholder="请输入" name="account" @keyup.enter="Login">
                        </div>
                        <div class="login-input">
                            <img src="../../static/icons/密码(1).png" alt="">
                            <input type="password" placeholder="请输入密码" name="password" @keyup.enter="Login">
                        </div>
                        <a href="" class="forget-psw">忘记密码</a>
                        <div class="login-btn active">
                            <a @click="Login">登录</a>
                        </div>
                        <div class="login-btn">
                            <a :href="active!=2?'register.html':'register-station.html'">注册</a>
                        </div>
                        <p>欢迎登录家园生活服务网</p>
                    </form>
                </div>
            </div>
        </div>
    </div>
</main>
</div>

<script src="../../jsc/common.js"></script>
<script src="../../jsc/component.js"></script>
<script>


    function exchange(obj) {
        $(".login-tab").removeClass("active");
        $(obj).addClass("active");
    }
    new Vue({
        el:"#app",
        data:{

            detail:{},
            active:1,

        },
        mounted(){
            var _th = this;


        },
        filters:{

        },
        methods:{
            exchange:function (str) {
                this.active = str
            },
            loginOut:function () {
                //退出登录
                layer.confirm("确定退出登录？",{ btn:["确定","取消"]},function () {
                    delCookie("token");
                    window.location.href = "login.html"
                },function (index) {
                    layer.close(index);
                })
            },
            Login:function () {
                var formdata = new FormData(document.forms.namedItem("content"))
                axios.post(sysurl + 'user/login', formdata)
                    .then(res => {
                        if (res.data.code === 1) {
                            layer.msg(res.data.msg,function () {
                                setCookie("token",res.data.data.userinfo.token);
                                setCookie("user_id",res.data.data.userinfo.user_id);
                                window.location.href = tmpsUrls+"www/index.html"
                            })
                        }
                        else {
                            layer.msg(res.data.msg);
                        }
                    }, err => {

                    })
                    .catch((error) => {

                    })
            },
            Register:function () {
                if(this.active === 1){
                    window.location.href = ''
                }
            }


        }
    })
</script>
</body>
</html>